package com.dmlll.service.impl;

import com.dmlll.VO.AccountVO;
import com.dmlll.VO.ParticularsVO;
import com.dmlll.VO.RegisterMessageVO;
import com.dmlll.dao.PopulaceUserMapper;
import com.dmlll.pojo.PopulaceUser;
import com.dmlll.service.PopulaceUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PopulaceUserServiceImpl implements PopulaceUserService{

    @Autowired
    private PopulaceUserMapper populaceUserMapper;

    @Override
    public int insertUser(PopulaceUser populaceUser) {
        return populaceUserMapper.insertUser(populaceUser);
    }

    @Override
    public PopulaceUser login(String userAccount) {
        return populaceUserMapper.login(userAccount);
    }

    //账户管理
    @Override
    public PageInfo<AccountVO> selectAll(String userPhone,Integer pageNum, Integer pageSize,Integer grade) {
        PageHelper.startPage(pageNum,pageSize);
        List<AccountVO> list = populaceUserMapper.selectAll(userPhone,grade);
        PageInfo<AccountVO> pageInfo = new PageInfo<>(list);
        return pageInfo;

    }

    //注册信息审核
    @Override
    public PageInfo<RegisterMessageVO> selectRegister(String userPhone, Integer pageNum, Integer pageSize,Integer accountGrade) {
        PageHelper.startPage(pageNum,pageSize);
        List<RegisterMessageVO> list = populaceUserMapper.selectRegister(userPhone,accountGrade);
        PageInfo<RegisterMessageVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public ParticularsVO selectExamine(Integer id) {
        return populaceUserMapper.selectExamine(id);
    }


    //修改审核状态（通过）
    @Override
    public int updateAudit(Integer[] idList) {
        return populaceUserMapper.updateAudit(idList);
    }

    //修改审核状态（不通过）
    @Override
    public int updateAuditNO(Integer[] idList,String notPassCause) {
        return populaceUserMapper.updateAuditNO(idList,notPassCause);
    }

    @Override
    public List<PopulaceUser> selectUserAccount() {
        return populaceUserMapper.selectUserAccount();
    }


}
